<?php
/*
 * Last Edited: 27-7-2013
 */
class PromotionEventModel extends Zend_Db_Table_Abstract{
	protected $_name = 'promotion_event';
	protected $_primary = 'id';
    
    public function getPromotion($userId){
    	$db = Zend_Registry::get("connectDB");
    	$select = $db->select()
    		->from("promotion_event",array("detail","promotion"))
    		->joinLeft("user_promotion", "promotion_event.id = user_promotion.event_id",null)
    		->where("NOW() BETWEEN promotion_event.start_time AND promotion_event.end_time" )
    		->where("promotion_event.type = 1")
    		->orWhere("user_promotion.user_id = ?" ,$userId)
    		->order("promotion DESC")
    		->limit(1);
    	return $db->fetchRow($select);
    }
}